<form class="layui-form layui-box modal-form-box" action="{:request()->url()}" data-auto="true" method="post">


    <div class="layui-form-item">
        <label class="layui-form-label">机器码</label>
        <div class="layui-input-block">
            <input type="text" name="machine_no" value='{$vo.machine_no|default=""}' required="required" title="请输入机器码" placeholder="请输入6位数字的机器码" class="layui-input">
            <p class="help-block color-desc"><b>必填</b></p>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">思迈尔IMEI</label>
        <div class="layui-input-block">
            <input type="text" name="imei" value='{$vo.imei|default=""}' title="请输入IMEI" placeholder="请输入IMEI" class="layui-input">
            <p class="help-block color-desc"><b>思迈尔必填</b></p>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">品牌型号</label>
        <div class="layui-input-block">
            <select name="machine_type_id" id="machine_type_id" lay-verify="required" class="layui-input" style="display: block; width: 300px;">
                <option value="">请选择品牌型号</option>
                {foreach $machine_type as $mt }
                <option value="{$mt.id}"  {if condition="isset($machine['machine_type_id']) && $machine['machine_type_id'] == $mt.id "} selected="selected"{/if} >{$mt.supplier} - {$mt.brand} - {$mt.name}</option>
                {/foreach}
            </select>
            <p class="help-block color-desc"><b>必填</b></p>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">机器地区</label>
        <div class="layui-input-block">
            <select name="area" id="area_id" lay-verify="required" class="layui-input" style="display: block; width: 300px;">
                <option value="">请选择地区</option>
                {foreach $areas as $area }
                <option value="{$area.id}"  {if condition="isset($machine['area_id']) && $machine['area_id'] == $area.id "} selected="selected"{/if} >{$area.area_name}</option>
                {/foreach}
            </select>
            <p class="help-block color-desc"><b>必填</b></p>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">机器具体位置</label>
        <div class="layui-input-block">
            <input type="text" name="dormitory_num" value='{$vo.dormitory_num|default=""}'  title="请输入机器具体位置" placeholder="请输入机器具体位置" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">机器卡号</label>
        <div class="layui-input-block">
            <input type="text" name="rfid" value='{$vo.rfid|default=""}'  title="请输入机器卡号" placeholder="请输入机器卡号" class="layui-input">
            <p class="help-block color-desc"><b>必填</b></p>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">代理人</label>
        <div class="layui-input-block">
            <select name="user_id" id="user_id" lay-verify="required" class="layui-input" style="display: block; width: 300px;">
                <option value="">请选择代理人</option>
                {foreach $user as $item }
                <option value="{$item.id}" {if condition="isset($machine['user_id']) && $machine['user_id'] == $item.id "} selected="selected"{/if}  >{$item.username}</option>
                {/foreach}
            </select>
            <p class="help-block color-desc"><b>必填</b></p>
        </div>
    </div>


    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'>{/if}
        {if isset($edit)}<input type="hidden" name="edit" value="true">{/if}
        <button class="layui-btn" id="submit" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>


</form>

<script type="text/javascript">
    $("#submit").click(
        function () {
            //校验地区
            area = parseInt($("#area_id").val());
            if (!area) {
                layer.msg('请选择正确的地区', {icon: 2});
                return false;
            };

        }
    );
</script>